.PHONY: all speed stealth tele clean botdll dlltool packetlogger

AS=as
ASFLAGS=
CFLAGS=-Wall -Wextra -std=c99
CC=gcc
LD=gcc
LDFLAGS=-s -lm

all: speed stealth tele botdll dlltool packetlogger

botdll: obj/rombot.o obj/log.o obj/thiscall.o obj/combat.o obj/envhook.o obj/envhookbridge.o bin
	$(LD) $(LDFLAGS) -shared obj/thiscall.o obj/rombot.o obj/log.o obj/combat.o obj/envhook.o obj/envhookbridge.o -o bin/rombot.dll

packetlogger: bin obj/packetlogger.o obj/loggerstub.o
	$(LD) $(LDFLAGS) -shared obj/packetlogger.o obj/loggerstub.o -o bin/packetlogger.dll

obj/combat.o: obj
	$(CC) $(CFLAGS) -c src/combat.c -o obj/combat.o

obj/rombot.o: obj
	$(CC) $(CFLAGS) -c src/rombot.c -o obj/rombot.o

obj/log.o: obj
	$(CC) $(CFLAGS) -c src/log.c -o obj/log.o

obj/thiscall.o: obj
	$(AS) $(ASFLAGS) src/thiscall.s -o obj/thiscall.o

obj/envhook.o:
	$(CC) $(CFLAGS) -c src/envhook.c -o obj/envhook.o

obj/loggerstub.o: obj
	$(AS) $(ASFLAGS) src/loggerstub.s -o obj/loggerstub.o

obj/packetlogger.o: obj
	$(CC) $(CFLAGS) -c src/packetlogger.c -o obj/packetlogger.o

obj/envhookbridge.o: obj
	$(AS) $(ASFLAGS) src/envhook.s -o obj/envhookbridge.o

speed: bin
	$(CC) $(CFLAGS) src/speedhack.c -o bin/speedhack.exe

stealth: bin
	$(CC) $(CFLAGS) src/stealthhack.c -o bin/stealthhack.exe

tele: bin
	$(CC) $(CFLAGS) src/telehack.c -o bin/telehack.exe

dlltool: bin
	$(CC) $(CFLAGS) -s src/dlltool.c -o bin/dlltool.exe

obj:
	mkdir obj

bin:
	mkdir bin

clean:
	rm -rf bin/ obj/
